/* 	ObjectSingle
 *	Nice calendar navigation
 */

var ObjectSingle = function( action )	{

	Object.extend( obj = $$( '.ObjectSingle' ).pop(), ObjectSingle.proto );
	Object.extend( obj, ObjectSingle[ "proto_" + action ]);
	
	obj.init();	
	return obj;
}


ObjectSingle.proto = {
	
	current		: 0,
	
	bubble		: function() {}

}

ObjectSingle.proto_extended = {
	
	init		: function() {
		
		this.select( "img" ).invoke( "observe", "click", this.bubble.bind( this ) ).invoke( "observe", "mouseover", this.hover.bind( this ) ).invoke( "observe", "mouseout", this.blur.bind( this ) );
		this.up(0).observe( "mouseout", this.toggle );
	},
	
	active_img	: function( ref ) {
		
		this.select( "img" ).invoke( "setOpacity", 1 );
		
		this.img = (typeof ref == "number" )? this.select( "img" )[ ref ] : ref;
		this.img.setOpacity( 0.6 );
	},
	
	bubble		: function( e ) {
		img = e.element( e ); //e.currentTarget;
		$( 'photo' ).src = "/public.img?id=" + img.readAttribute( 'rel' ) + "&sze=980.664";
		this.active_img( img );
		//this.up(0).setOpacity( 0.12 );
	},
	
	hover		: function( e ) {
		img = e.element( e ); //e.currentTarget;
		img.setOpacity( (img == this.img )? 0.5 : 0.9 );
	},
	
	blur		: function( e ) {
		img = e.element( e ); //e.currentTarget;
		img.setOpacity( (img == this.img )? 0.6 : 1 );
	},
	
	toggle		: function() {
	
		this.setOpacity( 0.12 );
		this.observe( "mouseover", function() { this.setOpacity(1); } );
	}
}


